Image processing apparatus and its method

ABSTRACT

It is desired to easily and effectively correct hue and saturation in a predetermined region, for an image which cannot be desirably corrected by conversion of the brightness or colors of the entire image. To this end, an image is loaded onto a RAM, and the contrast and color balance of the input image are corrected. A predetermined region is extracted from the corrected image, and it is checked if a predetermined region is set. If the predetermined region is set, a color correction process of the predetermined region is executed.

FIELD OF THE INVENTION

The present invention relates to an image processing apparatus and itsmethod and, more particularly, to a color correction process of a colorimage in a color image device such as a digital camera, scanner,display, printer, or the like, and image processing software.

BACKGROUND OF THE INVENTION

Color appearance of a color image device must faithfully reproduce anoriginal color. On the other hand, color appearance favored by people isalso important and, especially, flesh color, sky blue, plant green, andthe like must be color appearance favored by people. For example, whenan object image is sensed by a digital camera and is recorded as digitalimage data, exposure is controlled upon image sensing, and the colorbalance, hue, saturation, and tone of color image data output from animage sensor are corrected, so as to obtain an image with appropriatebrightness.

However, these processes associated with color conversion correct thebrightness and colors of the entire image but cannot individuallycorrect a color to be corrected. For this reason, when correction isapplied to have a color to be corrected as a target color, other colorsare influenced, and the entire image is not always corrected tofavorable colors. For example, when a person in the shade is to besensed, if the brightness level of his or her flesh is increased to atarget brightness level, other regions which originally have favorablebrightness levels become excessively bright. When the flesh color has abluish tint or is excessively yellowish due to the influence of localillumination, if it is corrected to a favorable color, the colors ofother regions which originally have favorable colors become unnatural.

In order to solve these problems, for example, “Image Signal Processingfor Hardcopy” by Hiroaki Kotera, The Journal of the Institute ofTelevision Engineers of Japan, Vol. 43, No. 11 (1989), pp. 1205-1212,introduces a selective color adjustment model. With this model, a colorregion which is to undergo color correction is designated, and the hueand saturation in the designated color region are corrected in afavorable direction.

According to the above reference, color adjustment is perceptually madeusing the hue correction amount and saturation scale. However, how todetermine the hue correction amount and saturation scale is notexplained in concrete terms. If color adjustment is made by setting thehue correction amount and saturation scale to be appropriate values, animage becomes unnatural due to too large a correction amount or anexpected effect cannot be obtained due to too small a correction amount.A method of confirming a correction result image by displaying it on adisplay or printing it using a printer, and exploring an optimal huecorrection amount and saturation scale while perceptually adjusting animage requires expert knowledge in adjustment or a huge number of timesof trials.

Given an image which cannot be desirably corrected by conversion of thebrightness or colors of the entire image, it is demanded to easily andeffectively apply correction of hue and saturation in a desired colorregion of such an image.

SUMMARY OF THE INVENTION

The first aspect of the present invention discloses a technique whichextracts predetermined regions from an input image, decides animportance level for each extracted region, determines a representativecolor to be corrected from those for respective extracted regions on thebasis of the importance levels, sets a color correction condition on thebasis of the representative color to be corrected, and applies colorcorrection to the input image on the basis of the color correctioncondition.

The second aspect of the present invention discloses a technique whichextracts predetermined regions from an input image, calculates colorcorrection conditions for respective extracted regions, decides animportance level for each extracted region, sets a color correctioncondition for the input image from the color correction conditionscalculated for respective regions on the basis of the importance levels,and applies color correction to the input image on the basis of thecolor correction condition.

According to the present invention, a predetermined region can beappropriately corrected.

Other features and advantages of the present invention will be apparentfrom the following description taken in conjunction with theaccompanying drawings, in which like reference characters designate thesame or similar parts throughout the figures thereof.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing the basic arrangement of an imageprocessing apparatus according to an embodiment of the presentinvention;

FIG. 2 is a block diagram showing the functional arrangement of theimage processing apparatus;

FIG. 3 is a flowchart showing an image correction process executed by aCPU;

FIG. 4 is a flowchart showing a color correction process of apredetermined color region executed by the CPU;

FIG. 5 is a flowchart showing extraction of a representative color;

FIG. 6 is a view for explaining an importance level based on abarycentric position;

FIG. 7 is a graph showing the relationship between the representativeluminance and importance level;

FIG. 8 is a view for explaining a method of setting a saturationcorrection coefficient Pc; and

FIG. 9 is a flowchart showing a setting process of a color region to becorrected.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Preferred embodiments of the present invention will be described indetail hereinafter with reference to the accompanying drawings.

An image processing apparatus of this embodiment comprises a computersuch as a personal computer (PC), workstation (WS), or the like. Theimage processing apparatus detects a predetermined color region orobject region from an image which is input from a digital camera orscanner, is downloaded from the Internet, or is loaded from a storagemedium such as a CD-ROM, DVD-ROM, or the like, and applies appropriatecorrection to that region. The image processing apparatus of thisembodiment that executes such process will be explained in more detailhereinafter. Especially, this embodiment will exemplify a case wherein apredetermined color region (e.g., a flesh color region) or apredetermined object region (human face region) is detected from animage sensed by a digital camera, and appropriate correction is appliedto that region.

[Arrangement]

FIG. 1 is a block diagram showing the basic arrangement of an imageprocessing apparatus according to this embodiment.

A CPU 201 controls the overall apparatus using programs and data storedin a RAM 202 and ROM 203, and executes various kinds of processing to bedescribed later.

The RAM 202 comprises an area for temporarily storing programs and datawhich are loaded from an external storage device 207 such as a hard diskor the like or a storage medium mounted on a storage medium drive device208, and also a work area used by the CPU 201 to execute various kindsof processing. The ROM 203 stores a boot program, setting data of theapparatus, and the like.

A keyboard 204 and mouse 205 are input devices used when the user inputsvarious instructions and information to the CPU 201. A display unit 206comprises a CRT, liquid crystal display, or the like, and the CPU 201displays a graphical user interface, and characters, images, and thelike indicating the processing result on the display unit 206.

The external storage device 207 is a large-capacity storage device suchas a hard disk drive device, which stores an operating system (OS), andprograms and data for making the CPU 201 execute various kinds ofprocessing to be described later. The programs and data stored in theexternal storage device 207 are loaded onto the RAM 202 under thecontrol of the CPU 201 as needed.

Programs and data recorded on a storage medium such as a CD-ROM,DVD-ROM, or the like mounted on the storage medium drive device 208 areloaded onto the RAM 202 or external storage device 207 under the controlof the CPU 201 as needed. Some of programs and data stored in theexternal storage device 207 may be recorded on the storage medium. Whenthese programs and data are used, the CPU 201 controls the storagemedium drive device 208 to read out the programs and data and to storethem in the RAM 202.

An interface (I/F) 209 comprises a serial bus interface such as USB(Universal Serial Bus), IEEE1394, and the like, which are used toconnect a digital camera, printer, and the like, and a network interfacewhich is used to connect a network line such as the Internet, LAN, orthe like.

The aforementioned components are connected to each other via a systembus 210.

[Functional Arrangement]

FIG. 2 is a block diagram showing the functional arrangement of theimage processing apparatus.

An image input unit 10 inputs image data to be processed from a digitalcamera or the like connected to the I/F 209. Of course, image data to beprocessed (to be referred to as “input image” hereinafter) may be inputfrom the external storage device 207, storage medium, or a server on thenetwork. Note that a person's face appears as an object in the inputimage.

An image correction unit 20 adjusts the contrast, color balance, and thelike of the input image. However, a method of adjusting them is notparticularly limited. For example, an adjustment method using ahistogram and tone curve is preferable. An image, in which apredetermined color such as a flesh color or the like is not reproducedto a favorable color irrespective of the adjustment of the imagecorrection unit 20, undergoes color correction of a predetermined colorregion by a color correction unit to be described later. Note that aflesh color region indicating a flesh color will be explained as atypical example of the predetermined color region, but the presentinvention can also be applied to color regions such as sky blue, plantgreen, sunset red, navy blue, and the like, which are associated withfavorable color appearance of people.

A predetermined color region setting unit 30 sets a predetermined colorregion to be corrected from the image corrected by the image correctionunit 20. However, the setting method is not particularly limited. Forexample, a method of using face information detected by a face detectionunit, a method of designating an arbitrary hue or saturation value, andthe like may be used. Alternatively, the user may designate a colorregion or may designate or select an arbitrary hue or saturation valueby operating the keyboard 204 or mouse 205. Of course, the user maydesignate a rough image region, and face detection may be applied to thedesignated image region or a hue or saturation value may be designatedfor such an image region.

Further, the user can select a predetermined color region from theresult of segmentation which segments an input image. Furthermore, theuser can selects a region included in a specific region in a color spaceby obtaining a representative color of each segmented region. Anymethod, such as the method disclosed in JP 2001-043371, JP 2001-043388,JP 2003-143408, or the like, is available for the segmentation. Notethat the specific region in the color space is set in accordance with anobject should be extracted in advance, or the user can set the specificregion in the color space.

Furthermore, the predetermined color region setting unit 30 sets weightsbased on the position of an image region used when a correction unit 90performs correction, using the position information of the setpredetermined color region in the input image.

A representative color extraction unit 40 extracts a representativecolor from color information of the predetermined color region set bythe predetermined color region setting unit 30. Like flesh color regionsin a case wherein many people appear in a single image (e.g., a groupphotograph), a plurality of predetermined color regions-may exist in aninput image. In such case, the representative color extraction unit 40extracts representative colors from color information of respectivepredetermined color regions. The representative color includes, e.g.,the averages values, medians, modes, or the like of hue and saturationvalues of pixels within the predetermined color region.

When a plurality of predetermined color regions are set, as describedabove, a predetermined color region evaluation unit 42 decidesimportance levels of these predetermined color regions. When a pluralityof predetermined color regions are set, as described above, arepresentative color determination unit 44 determines one representativecolor for the entire input image on the basis of the representativecolors extracted for respective predetermined color regions by therepresentative color extraction unit 40, and the evaluation results ofthe importance levels of the predetermined color regions of thepredetermined color region evaluation unit 42. When an input imageincludes only one predetermined color region like a flesh color regionin a case wherein only one person appears in one image (e.g., aportrait), the representative color determination unit 44 determines therepresentative color of that region as that for the entire input image,needless to say.

A target color memory 50 stores correction target colors correspondingto the colors of predetermined color regions in correspondence with thetypes of the predetermined color regions. A correction coefficientsetting unit 60 sets a correction coefficient used in the colorcorrection unit 90 on the basis of the correction target color stored inthe target color memory 50 and the representative color determined bythe representative color determination unit 44. A color region settingunit 70 sets a color region to be corrected by the color correction unit90, which includes the representative color determined by therepresentative color determination unit 44, from the color informationof the predetermined color regions extracted by the predetermined colorregion setting unit 30.

The color correction unit 90 applies color correction to the colorregion to be corrected set by the color region setting unit 70 using theweight based on the position of the image region set by thepredetermined color region setting unit 30, and the correctioncoefficient set by the correction coefficient setting unit 60. Thecolor-corrected image is output to, e.g., a printer, the externalstorage device 207, or a server on the network by an image output unit100. Alternatively, the color-corrected image may be returned to thedigital camera that inputs the original image, and may be stored as anew image or may be overwritten on the original image on its storagemedium.

[Processing Sequence]

FIG. 3 is a flowchart showing an image correction process executed bythe CPU 201.

An input image is loaded onto the RAM 202 (S1). The loading method isnot particularly limited. For example, the user may designate a filename of image data to be processed saved on the external storage device207, storage medium, or server using the keyboard 204 or mouse 205, soas to instruct the CPU 201 to load it. Alternatively, the user mayconnect a digital camera (or scanner) to the I/F 209, and may instructthe digital camera (or scanner; in practice, driver software for each ofthese devices, which is loaded onto the RAM 202) to transfer image datasaved in the internal memory of the digital camera (or image datascanned by the scanner) to the RAM 202, thus loading the image data tobe processed onto the RAM 202.

The image data to be processed is an RGB image in which each channel ofone pixel is expressed by 8 bits, and its image size is an M×N pixels (Mis the number of pixels in the horizontal direction, and N is the numberof pixels in the vertical direction). The image data to be processed isformed of a total of three planes, i.e., a plane formed of only R (red)pixel values, a plane formed of only G (green) pixel values, and a planeformed of only B (blue) pixel values. However, the present invention isnot limited to this, and a color image formed of one plane may be used.Furthermore, when the image data to be processed is compressed by, e.g.,JPEG, the CPU 201 decompresses the image data to generate an image inwhich each pixel is expressed by R, G, and B color components.

The bit length of each channel of the image data is not limited to 8,and 12 bits, 16 bits, or the like per channel may be used.Alternatively, pixel value expression is not limited to an integer, andreal values may be used.

The following description will be given using the RGB image. Even whenother color spaces such as LCH, YCbCr, L*u*v*, HSV, HSL, and the likeare used, they can be converted into a color space to be processed bythis embodiment in a previous stage, and appropriate processes can bemade. In this case, when the color space of image data is the same asthat to be processed by this embodiment, the processes may be made bydirectly using original image data.

The contrast of the input image loaded onto the RAM 202 is corrected(S2). The correction method of this contrast correction process is notparticularly limited. For example, a method of appropriately correctingthe contrast using a luminance histogram or a tone curve that representsthe input/output relationship or the like may be used. Next, the colorbalance of the input image is appropriately corrected (S3). This colorbalance correction method is not particularly limited. For example, acolor balance method that uses a histogram or a tone curve thatrepresents the input/output relationship or the like may be used.

A predetermined color region is extracted from the corrected image inaccordance with the predetermined color region setting of thepredetermined color region setting unit 30 (S4), and it is checked if apredetermined color region is set (S5). If no predetermined color regionis set, the corrected image is output to, e.g., the printer, externalstorage device 207, server on the network, or the like (S7). If thepredetermined color region is set, the aforementioned color correctionunit 90 executes a color correction process of the predetermined colorregion (S6), and the corrected image is then output (S7).

The extraction method of a predetermined color region is notparticularly limited. For example, when a flesh color region is used, amethod of using face information detected by a face detection process, amethod of designating an arbitrary hue or saturation value, or the likemay be used. Further, the input image is segmented by the segmentation,the representative color of each segmented region is obtained, andevaluation, which determines whether or not the representative color isincluded in the specific region of the color space, is executed so as toselect a region. Note that the specific region in the color space is setin accordance with an object should be extracted in advance, or the usercan set the specific region in the color space.

When a face region including a face of an object is used, apredetermined color region may be automatically set using the facedetection process, or the user may interactively set a predeterminedcolor region using the keyboard 204 or mouse 205 by displaying an imageon the display unit 206. In the processes of this embodiment, ifposition information of a face region is available, it suffices for theprocesses to be described later. Hence, an image used to set the faceregion may be either an image before or after the processes in steps S2and S3.

A method of using face information of a face detection result will bedescribed as one example. As a process for detecting a face region in animage, a face rectangular region can be detected using a methoddescribed in Yang, et al. “Detecting Faces in Images: A Survey” IEEETRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 24, No.1, January 2002. Two pieces of position information of the detected twoeyes are acquired, and a predetermined rectangular region having, assides, a line segment that connects the two eyes, and a line segmentperpendicular to that line segment is defined, and the average value andcovariance matrix of RGB values of pixels in that rectangular region arecalculated. These RGB average value and covariance matrix, and theMahalanobis distances of RGB values of respective pixels in the detectedface rectangular region are calculated. A pixel equal to or lower than athreshold is determined as a flesh color pixel, and a set of such pixelsis determined as a flesh color region.

Furthermore, spatial coupling of flesh color regions on the image ischecked, and coupled flesh color regions are combined to set an imageregion. This process is implemented by, e.g., checking coupling of fleshcolor pixels, and assigning identical labels to coupled flesh colorpixels. Preferably, in this case, an image region as a small region isremoved, although this process is not indispensable. For example, athreshold used to determine a small region is set in advance, and whenthe number of pixels of a given image region is equal to or smaller thanthe threshold, that image region is excluded.

In this way, the extracted predetermined color regions are labeled. Thatis, a label number is assigned to a pixel which belongs to apredetermined color region (e.g., a label number “0” for a region otherthe predetermined color region, and a label number “j” for the j-thpredetermined color region). Note that the label numbers are stored inthe RAM 202 in correspondence with the pixel positions of the inputimage.

Color Correction Process of Predetermined Color Region (S6)

FIG. 4 is a flowchart showing the color correction process of apredetermined color region (S6) executed by the CPU 201.

The input image expressed by respective values of the RGB color space isconverted into an LCH color space (lightness L, saturation C, and hue H)(S11). Note that the color space after conversion is not limited to LCH,but other color spaces such as YCbCr, L*u*v*, HSV, HSL, and the like maybe used.

In order to execute a repetition process, the number of extractedpredetermined color regions is set in a variable N, and counter k isreset to zero (S12). Then, a representative color is extracted from thek-th predetermined color region (S13), and counter k is incremented(S14). Then, the processes in steps S13 and S14 are repeated until it isdetermined in step S15 that k=N, thus extracting representative colorsof respective predetermined color regions.

FIG. 5 is a flowchart showing the representative color extractionprocess (S13).

A pixel of interest is acquired from the input image (S41), and it ischecked with reference to the label number assigned to the pixel ofinterest if the pixel of interest is a pixel in the k-th predeterminedcolor region (S42). If the pixel of interest is a pixel in the k-thpredetermined color region, it is checked if a lightness value L of thepixel of interest is equal to or larger than a threshold Lth (S43). Forexample, in case of a flesh color region, if the extracted area includesan eye, eyebrow, mustache, or shadow, a representative color cannotoften be appropriately obtained. Hence, by the checking processes insteps S42 and S43, pixels that form a region such as a shadow, eye,eyebrow, or mustache, which may have a low lightness value than a fleshcolor to be corrected, are excluded.

Next, saturation C and hue H of the pixel of interest which meets theconditions in steps S42 and 43 are compiled (S44). This compiling methodvaries depending on a representative color to be adopted. For example,when the average value of pixels is used as a representative color,saturation values C and hue values H are simply added up, and the numberof pixels for which the sums are compiled is counted.

The pixel of interest is shifted (S45). It is checked if all the pixelsof the input image are checked (S46). The processes in steps S41 to S45are repeated until all the pixels are checked. Upon completion ofexamination for all the pixels of the input image, the representativecolor of the k-th predetermined color region is set (S47). When theaverage values of saturation values C and hue values H of pixels in thepredetermined color region are used as a representative color, values Crand Hr obtained by dividing the sums in step S44 by the count value areset as a representative color.

In the example of the above description, the representative colors of Npredetermined color regions are extracted by the repetition process instep S13. Alternatively, when a process for checking to whichpredetermined pixel region the pixel of interest belongs is added to theprocess in step S42 shown in FIG. 5, and saturation value C and huevalue H are compiled for each predetermined color region to which thepixel belongs in step S44, the representative colors of N predeterminedcolor regions can be simultaneously set in step S47. In this case, therepetition process can be omitted.

Referring back to the processing shown in FIG. 4, an importance level ofeach predetermined color region is decided (S16). For example, animportance level is calculated on the basis of the area of apredetermined color region (the number of pixels which belong to thatregion), the position of the predetermined color region on the inputimage, and a representative luminance value of the predetermined colorregion. In the following description, let S(k) be the area, I(k) be theimportance level, Is(k) be the importance level based on the area, Ip(k)be the importance level based on the position, and Ib(k) be theimportance level based on the luminance of the k-th (0<k<N)predetermined color region.

An importance level Is(k) based oni the area is calculated first. Thearea S(k) of the predetermined color region is calculated frominformation which expresses that region. If the shape of the region is arelatively simple shape such as a rectangle, circle, ellipse, triangle,or the like, numerical values required to calculate its area (e.g., thenumbers of pixels in the vertical and horizontal directions for arectangle, the number of pixels of a radius for a circle, or the like)are examined to calculate the area. However, in general, a predeterminedcolor region such as a flesh color region is likely to have anindeterminate form. In this case, the number of pixels (e.g., fleshcolor pixels) indicating the color of the predetermined color region iscounted. This can be implemented by labeling of the predetermined colorregion in step S4, or the extraction process of the representative colorin step S13.

Then, importance levels Is(0) to Is(N-1) are calculated from areas S(0)to S(N-1). Note that a value obtained by normalizing the area of eachpredetermined color region by the maximum value of the area of thepredetermined color region is used.Is(k)=S(k)/Smax   (1)where Smax is the maximum value of S(0) to S(N-1).

The importance level calculation formula of equation (1) is an example,and it is easy to-make a modification which normalizes using the totalarea of the predetermined color regions. Of course, other calculationformulas may be used.

Next, an importance level Ip(k) based on the position of thepredetermined color region is calculated. The barycenter of thepredetermined color region is calculated first, and the importance levelIp(k) based on the position is calculated from the coordinate value ofthe barycenter.

FIG. 6 is a view for explaining the importance level based on thebarycentric position. In FIG. 6, a central portion 602 of an image 601is a range where a relatively principal object (or the center of theobject) is assumed to be located. An importance level Iph based on thehorizontal position and an importance level Ipv based on the verticalposition are defined. The importance levels Iph and Ipv in the centralportion 602 are set to be “1”, are decreased toward the periphery of theimage 601, and are set to be “0” at the image end. More specifically,when a normalized coordinate of the barycenter in the horizontaldirection falls within the range from h1 to h2, the importance levelIph=1; when a normalized coordinate of the barycenter in the verticaldirection falls within the range from v1 to v2, the importance levelIpv=1; otherwise, each importance level assumes a value ranging from 0(inclusive) to 1 (exclusive). The importance level Ip(k) based on theposition is calculated by:Ip(k)=Iph(k)×Ipv(k)   (2)

Of course, Ip(k) may be calculated as the average value, maximum value,or minimum value of Iph(k) and Ipv(k). Also, the central portion 602shown in FIG. 6 is not limited to a rectangle but may be a circle,ellipse, or the like.

Then, an importance level Ib(k) based on the luminance of thepredetermined color region is calculated. A representative luminance ofthe predetermined color region is determined first. The representativeluminance can be calculated by compiling luminance values L as inextraction of the representative color in step S13 (compiling saturationvalues C and hue values H). Then, the average luminance (or weightedaverage value, median, maximum value, minimum value, mode, or the like)is calculated from the compiling result of the luminance values L, andis defined as the representative luminance of that region. Of course,the luminance values may be compiled as a histogram, and therepresentative luminance may be calculated by analyzing the histogram.In this way, compiling of luminance values L required to determine therepresentative luminance need not be done in step S16 but may be doneduring extraction of the representative color in step S13.

FIG. 7 is a graph showing the representative luminance and importancelevel Ib(k). For example, an appropriate brightness of a flesh color ina flesh color region is generally about 60 to 90% of a maximum luminancein an image. ThMin and ThMax in FIG. 7 respectively indicate minimum andmaximum values of the appropriate brightness of a color of thepredetermined color region. The correspondence between the brightnessand importance level Ib(k), as shown in FIG. 7, is defined in advance,and the importance level Ib(k) based on the luminance is calculated fromthe representative luminance of each predetermined color region.

Of course, the relationship between the luminance and importance levelshown in FIG. 7 is an example, and other relationships may be used.

The importance level I(k) of each predetermined color region isdetermined based on the importance level Is(k) based on the area, theimportance level Ip(k) based on the position, and the importance levelIb(k) based on the luminance, which are calculated as described above.I(k)=Is(k)×Ip(k)×Ib(k)   (3)

Of course, the calculation of the importance level I(k) is not limitedto a multiplication of the three importance levels. For example, theaverage value, weighted average value, maximum value, minimum value,median, or the like may be calculated, as long as a method ofcalculating the importance level in consideration of the area, position,and luminance of the predetermined color region that this embodimentintended is used. Also, in addition to the importance levels based onthe area, position, and luminance of the predetermined color region, animportance level for other regions may be set, and the importance levelof the predetermined color region may be determined in consideration ofit. Furthermore, all the importance levels based on the area, position,and luminance are not always indispensable, and modifications which donot use any of these levels are available. That is, means for evaluatingan importance level of an image region is provided to evaluate eachimage region, and the importance level of the predetermined color regioncan be determined.

One representative color for the whole image is determined from therepresentative colors of respective predetermined color regions (S17).In the following description, let (Cr(k), Hr(k)) be a representativecolor of the k-th region, and (Cr, Hr) be one representative color forthe whole image, which is determined in step S17.

Each representative color is converted into a*b* data. This processcorresponds to conversion of CH data in a polar coordinate system (C-Hcoordinate system) into an x-y coordinate system by:a*(k)=Cr(k)×cos(Hr(k))b*(k)=Cr(k)×sin(Hr(k))   (4)

Then, the weighted averages of (a*(k), b*(k)) are calculated using theimportance level I(k) of each predetermined color region.ar*={Σ _(k) a*(k)×I(k)}/Σ_(k) I(k)br*={Σ _(k) b*(k)×I(k)}/Σ_(k) I(k)   (5)

Then, (ar*, br*) is re-converted to the C—H coordinate system tocalculate (Cr, Hr).Cr=√(ar* ² +br* ²)Hr=tan θ⁻¹(br*/ar*)   (6)

When a predetermined color region (e.g., a flesh color region) hasrelatively uniform hue values to some extent, the weighted averages of(Cr(k), Hr(k)) may be simply calculated to calculate a representativecolor (Cr, Hr). Alternatively, the representative color of a regionhaving a maximum importance level of the respective predetermined colorregions may be selected as the representative color of the whole image.

Target color data is acquired from the target color memory 50 (S18), andcorrection coefficients used to control correction amounts in colorcorrection are set on the basis of the difference between therepresentative color and target color (S19). Since the correctionamounts in color correction are set in correspondence with hue H andsaturation C, correction coefficients are also set as a hue correctioncoefficient Ph and saturation correction coefficient Pc.

The hue correction coefficient Ph is set to decrease with increasingdifference between a hue value Ht of the correction target color and thehue value Hr of the representative color, as described, e.g., by:Ph( H _(dist))=K1·exp(−H _(dist) ² /t1)   (7)where K1 and t1 are constants.H _(dist) =|Ht−Hr|

That is, the correction coefficient Ph is set so as to apply correctionthat makes the hue value Hr of the representative color become closer tothe hue value Ht of the target color as the hue value Hr of therepresentative color of the color to be corrected is closer to the huevalue Ht of the target color, and not to apply much correction when thehue value Hr of the representative color is largely distant from the huevalue Ht of the target color. The reason why the correction coefficientis set in this way is as follows. That is, when the hue value Hr(k) ofthe representative color of the color to be corrected is largely distantfrom the hue value Ht of the target color, if correction is made to makethe representative color become closer to the target color, the colorbalance of the entire input image is lost.

Likewise, the saturation correction coefficient Pc is set to decreasewith increasing difference between a saturation value Ct of the targetcolor and the saturation value Cr of the representative color. That is,the correction coefficient Pc is set so as to apply correction thatmakes the saturation value Cr of the representative color become closerto the saturation value Ct of the target color as the saturation valueCr of the representative color of the color to be corrected is closer tothe saturation value Ct of the target color, and not to apply muchcorrection when the saturation value Cr of the representative color islargely distant from the saturation value Ct of the target color.However, the saturation correction coefficient Pc is set using differentsetting methods for a case wherein correction is made to decreasesaturation, and a case wherein correction is made to increasesaturation. When the saturation level is to be decreased, it isdesirable to set the correction coefficient to prevent the impression ofthe image from becoming unspectacular. Conversely, when the saturationlevel is to be increased, even when the saturation value Cr of therepresentative color of the color to be corrected is distant from thesaturation value Ct of the target color, correction is made to make itbecome closer to the saturation value Ct of the target color, so thatthe effect of improving the impression of the image can be expected. Asthe setting method of the saturation correction coefficient Pc, when thesaturation level is to be increased, equation (8) is used; when thesaturation level is to be decreased, equation (9) is used:

When Ct<CrPc( C _(dist))=−a1·C _(dist) ² +b1   (8)

When Ct≧CrPc( C _(dist))=K2·exp(−C _(dist) ² /t2)   (9)where a1, b1, K2, and t2 are constants.C _(dist) =|Ct−Cr|

FIG. 8 is a graph showing equations (8) and (9). The abscissa plots thedifference between the saturation value Ct of the target color and thesaturation value Cr(k) of the representative color, and the ordinateplots the saturation correction coefficient Pc. As can be seen from FIG.8, the saturation correction coefficient (solid curve) in correction todecrease saturation and that (dotted curve) in correction to increasesaturation have different values even when they have an equal saturationdifference, as indicated by C1 in FIG. 8, and the saturation correctioncoefficient (solid curve) in correction to decrease saturation assumes asmaller value. This indicates that when correction is made to decreasesaturation, a correction amount becomes smaller than that used whencorrection is made to increase saturation.

Next, a color region to be corrected is set (S20). FIG. 9 is a flowchartshowing the setting process of a color region to be corrected (S20).

Upon setting the color region, paying attention to the hue values ofpixels in the predetermined color region, a color region which includesthe representative color to be corrected is set, and that region is setas a target region for color correction. This is to prevent thefollowing problem: when correction that changes a flesh color to afavorable one is applied to the entire region of the input image, thecolors of other regions in the image, which are originally favorablecolors, become unnatural.

A pixel of interest is acquired from the input image (S31). It ischecked if the pixel of interest is a pixel of the predetermined colorregion (S32). If the pixel of interest is a pixel of the predeterminedcolor region, it is checked if a lightness value Lt of the pixel ofinterest is equal to or larger than a threshold Lth (S33). The checkingprocesses in steps S32 and S33 are to exclude pixels that form a regionsuch as an eye, eyebrow, mustache, or shadow included in the extractedregion in case of, e.g., a flesh color region, as in extraction of therepresentative color.

For the pixel which meets the conditions in steps S32 and S33, it ischecked if a saturation value C of that pixel is equal-to or larger thana saturation threshold Cth of an achromatic color (S34). When thesaturation value C of the pixel of interest is less than the thresholdCth, this means that the pixel of interest is boundlessly close to anachromatic color. The reason why an achromatic color pixel is excludedis to prevent the following problem: hue values change considerably dueto slight differences of RGB values in an achromatic color region, and ahue region corresponding to the predetermined color region cannot bedetermined with high precision.

For the pixel of interest that meets the conditions in steps S32 to S34,the hue value H of that pixel is compiled (S35). This compiling methodvaries depending on a specific hue value to be adopted indicating thepredetermined color region. For example, a method of analyzing the huedistribution of pixels which meet the conditions in steps S32 to 34, andindicating a color region to be corrected by a maximum hue value Hmaxand minimum hue value Hmin may be used.

The pixel of interest is shifted (S36). It is checked if all the pixelsof the input image are checked (S37). The processes in steps S31 to S36are repeated until all the pixels are checked. Upon completion ofexamination for all the pixels of the input image, the color region tobe corrected is set (S38). When the color region to be corrected isindicated by the aforementioned maximum hue value Hmax and minimum huevalue Hmin, a color region to be corrected is set based on thedifference from the representative hue value Hr using the maximum andminimum hue values as the compiling results, as described, e.g., by:ΔH=max(|Hmax−Hr|, |Hmin−Hr|)   (10)where the function max( ) is a function that selects a maximum one ofvalues in the parentheses.

That is, the color region to be corrected is set as a hue range thatincludes the predetermined color region extracted in step S4 in FIG. 3.

In the above example, the maximum hue value Hmax and minimum hue valueHmin are automatically derived from the hue distribution of a pixelgroup which meets the conditions in steps S32 to S34. However, thesetting method of a specific hue indicating the color region to becorrected is not limited to this. Depending on the state of the inputimage, for example, it is often preferable that the user manually setsan arbitrary hue region or selects a hue region registered in advance inthe target color memory 50. However, even in such case, the color regionto be corrected is preferably set as the hue range that includes thepredetermined color region extracted in step S4. Hence, if thepredetermined color region is insufficiently included with respect tothe user's setting or selection, it is desirable to take an action,e.g., generation of a warning, or the like.

For the set color region, weights of the color region to be used incolor correction to be described later are set for each hue range andsaturation range (S39).

A hue weight Wh is set to have “1” for the representative color or “0”for a region outside the color region to be corrected by:

When H falls within the range Hr+AHWh=|H−Hr|/ΔH

When H falls outside the rangeWh=0   (11)This is to prevent the continuity of a color from collapsinginside/outside the hue region to be corrected upon executing colorcorrection to be described later.

However, the weight setting method is not limited to that described byequations (11). For example, a setting method which nonlinearly changesusing the hue range indicating the color region to be corrected,representative color, and an arbitrary constant or the like may be used.

A saturation weight Wc is set using the saturation value Cr of thetarget color and the saturation threshold Cth of an achromatic color by:

When C<CthWc=0

When Cth>C>CrWc=(C−Cth)/(Cr−Cth)   (12)

When C>CrWc=1

However, the weight setting method is not limited to that described byequations (12). For example, a method of setting the saturation weightWc by calculating a saturation range ΔC that includes the predeterminedcolor region by the same setting method of the hue region or the likemay be used.

The reason why the color region to be corrected is weighted is toprevent the continuity of a color from collapsing inside/outside the hueregion to be corrected upon executing color correction to be describedlater.

Referring back to the processing shown in FIG. 4, an image region weightused in color correction is set on the basis of the position informationof the predetermined color region in the input image (S21). Colorcorrection to be described later is made for only a predetermined colorusing the weights of each predetermined color region set in step S20,thus avoiding the colors of other regions in the image, which areoriginally favorable colors from becoming unnatural. However, when onlythe color region to be corrected is set, for example, if pixels whichare included in the hue range ΔH set in step S20 and fall outside thepredetermined color region exist in the input image, such pixels arealso to be corrected. Hence, as a method of solving such problem, theimage region weight set in step S21 is used.

The image region weight sets a value Wp(x,y) which falls within therange from 0 (inclusive) to 1 (inclusive) so as to apply colorcorrection to pixels in the predetermined color region, and not to applyany color correction to those which fall outside the k-th predeterminedcolor region (for 0≦x≦M-1, 0≦y≦N-1). Also, it is desired to set theimage region weight so as to prevent the continuity of a color near theboundary of the predetermined color region by color correction.

The method of setting the image region weight is not particularlylimited. For example, a method of calculating the barycenter of thepredetermined color region, and determining weights in accordance withthe distances between the barycenter and pixels may be used. When thissetting method is used, a correction amount for pixels near the boundaryof the predetermined color region becomes smaller than that for pixelsnear the center of the predetermined color region in color correction tobe described later, thus preventing the continuity of a color near theboundary of the predetermined color region. Also, in another method, alow-pass process may be applied to the predetermined color region usinga Gaussian filter or the like to soften a portion near the boundary ofthe predetermined color region, thus moderating collapsing of thecontinuity of a color inside/outside the predetermined color region.

Next, the hue and saturation values of pixels to be corrected in theinput image are corrected using the representative color of thepredetermined color region, the color region to be corrected includingthe representative color, and the image region weight (S22 and S23). Thecorrected image is converted into the RGB color space (S24). After that,the corrected image is output in step S7 shown in FIG. 3.

The hue correction in step S22 calculates a hue correction amount Dh inthe representative color. The hue correction amount Dh is expressed as aproduct of the difference between the hue value Ht of the target colorand the hue value Hr of the representative color, and the hue correctioncoefficient Ph (see equations (13)). The hue value H of each pixel ofthe input image is corrected by a product obtained by multiplying thehue region weight Wh, saturation region weight Wc, and image regionweight Wp by the hue correction amount Dh (see equations (13)):H′=H+W·DhDh=Ph(Ht−Hr)   (13)W=Wh·Wc·Wpwhere H is the hue value of the pixel before color correction, and H′ isthe hue value of the pixel after color correction.

Likewise, the saturation correction in step S23 calculates a saturationcorrection ratio Kc of the representative color from the saturationcorrection coefficient Pc, and the saturation value C of each pixel inthe input image is corrected by a product obtained by multiplying thehue region weight Wh, saturation region weight Wc, and image regionweight Wp by the saturation correction ratio Kc (see equations (14)).The saturation correction ratio Kc is expressed by the differencebetween the saturation value Ct of the target color and the saturationvalue Cr of the representative color, and the saturation correctioncoefficient Pc, as described by:C′=C(W−Kc+1)Kc=Pc(Ct−Cr}/Cr(Ct≠0)   (14)W=Wh·Wc·Wpwhere C is the saturation value of the pixel before color correction,and C′ is the saturation value of the pixel after color correction.

Modification of Embodiment

In the above embodiment, a case has been mainly explained wherein animage sensed by a digital camera is processed by a computer. Also, thepresent invention can be applied to the process of an image obtained byscanning a photograph or the like using a scanner. The functions of theabove embodiment can be installed not only in the computer but also in acolor image device main body such as a digital camera, scanner, display,printer, or the like.

In the above embodiment, the representative colors for respectivepredetermined color regions are combined in accordance with importancelevels to obtain a representative color for the input image, and thecolor correction condition is calculated in accordance with thisrepresentative color. However, the color correction condition may becalculated using other methods. For example, color correction conditionsmay be calculated for respective predetermined color regions, and may becombined in accordance with importance levels, thus calculating thecolor correction condition for the input image.

Other Embodiments

Note that the present invention can be applied to an apparatuscomprising a single device or to system constituted by a plurality ofdevices.

Furthermore, the invention can be implemented by supplying a softwareprogram, which implements the functions of the foregoing embodiments,directly or indirectly to a system or apparatus, reading the suppliedprogram code with a computer of the system or apparatus, and thenexecuting the program code. In this case, so long as the system orapparatus has the functions of the program, the mode of implementationneed not rely upon a program.

Accordingly, since the functions of the present invention areimplemented by computer, the program code installed in the computer alsoimplements the present invention. In other words, the claims of thepresent invention also cover a computer program for the purpose ofimplementing the functions of the present invention.

In this case, so long as the system or apparatus has the functions ofthe program, the program may be executed in any form, such as an objectcode, a program executed by an interpreter, or scrip data supplied to anoperating system.

Example of storage media that can be used for supplying the program area floppy disk, a hard disk, an optical disk, a magneto-optical disk, aCD-ROM, a CD-R, a CD-RW, a magnetic tape, a non-volatile type memorycard, a ROM, and a DVD (DVD-ROM and a DVD-R).

As for the method of supplying the program, a client computer can beconnected to a website on the Internet using a browser of the clientcomputer, and the computer program of the present invention or anautomatically-installable compressed file of the program can bedownloaded to a recording medium such as a hard disk. Further, theprogram of the present invention can be supplied by dividing the programcode constituting the program into a plurality of files and downloadingthe files from different websites. In other words, a WWW (World WideWeb) server that downloads, to multiple users, the program files thatimplement the functions of the present invention by computer is alsocovered by the claims of the present invention.

It is also possible to encrypt and store the program of the presentinvention on a storage medium such as a CD-ROM, distribute the storagemedium to users, allow users who meet certain requirements to downloaddecryption key information from a website via the Internet, and allowthese users to decrypt the encrypted program by using the keyinformation, whereby the program is installed in the user computer.

Besides the cases where the aforementioned functions according to theembodiments are implemented by executing the read program by computer,an operating system or the like running on the computer may perform allor a part of the actual processing so that the functions of theforegoing embodiments can be implemented by this processing.

Furthermore, after the program read from the storage medium is writtento a function expansion board inserted into the computer or to a memoryprovided in a function expansion unit connected to the computer, a CPUor the like mounted on the function expansion board or functionexpansion unit performs all or a part of the actual processing so thatthe functions of the foregoing embodiments can be implemented by thisprocessing.

As many apparently widely different embodiments of the present inventioncan be made without departing from the spirit and scope thereof, it isto be understood that the invention is not limited to the specificembodiments thereof except as defined in the appended claims.

CLAIM OF PRIORITY

This application claims priority from Japanese Patent Application No.2004-208882 filed on Jul. 15, 2004, which is hereby incorporated byreference herein.

1. A color processing method comprising the steps of: extracting predetermined regions from an input image; deciding importance levels for respective extracted regions; determining a representative color to be corrected from representative colors for respective extracted regions on the basis of the importance levels; setting a color correction condition on the basis of the representative color to be corrected; and applying color correction to the input image on the basis of the color correction condition.
 2. The method according to claim 1, wherein the deciding step includes a step of deciding the importance levels in accordance with areas of the regions.
 3. The method according to claim 1, wherein the deciding step includes a step of deciding the importance levels in accordance with positions of the regions in the input image.
 4. The method according to claim 1, wherein the deciding step includes a step of deciding the importance levels in accordance with luminance values of the regions.
 5. A color processing method comprising the steps of: extracting predetermined regions from an input image; calculating color correction conditions for respective extracted regions; deciding importance levels for respective extracted regions; setting a color correction condition for the input image from the color correction conditions calculated for respective regions on the basis of the importance levels; and applying color correction to the input image on the basis of the set color correction condition.
 6. A computer program for a color processing method, the method comprising the steps of: extracting predetermined regions from an input image; deciding importance levels for respective extracted regions; determining a representative color to be corrected from representative colors for respective extracted regions on the basis of the importance levels; setting a color correction condition on the basis of the representative color to be corrected; and applying color correction to the input image on the basis of the color correction condition.
 7. A computer program product stored on a computer readable medium, the program comprising computer program code for a color processing method, the method comprising the steps of: extracting predetermined regions from an input image; deciding importance levels for respective extracted regions; determining a representative color to be corrected from representative colors for respective extracted regions on the basis of the importance levels; setting a color correction condition on the basis of the representative color to be corrected; and applying color correction to the input image on the basis of the color correction condition.
 8. A computer program for a color processing method, the method comprising the steps of: extracting predetermined regions from an input image; calculating color correction conditions for respective extracted regions; deciding importance levels for respective extracted regions; setting a color correction condition for the input image from the color correction conditions calculated for respective regions on the basis of the importance levels; and applying color correction to the input image on the basis of the set color correction condition.
 9. A computer program product stored on a computer readable medium, the program comprising computer program code for a color processing method, the method comprising the steps of: extracting predetermined regions from an input image; calculating color correction conditions for respective extracted regions; deciding importance levels for respective extracted regions; setting a color correction condition for the input image from the color correction conditions calculated for respective regions on the basis of the importance levels; and applying color correction to the input image on the basis of the set color correction condition.
 10. A color processing apparatus comprising: an extractor, arranged to extract predetermined regions from an input image; a decider, arranged to decide importance levels for respective extracted regions; a determiner, arranged to determine a representative color to be corrected from representative colors for respective extracted regions on the basis of the importance levels; a setter, arranged to set a color correction condition on the basis of the representative color to be corrected; and a corrector, arranged to apply color correction to the input image on the basis of the color correction condition.
 11. A color processing apparatus comprising: an extractor, arranged to extract predetermined regions from an input image; a calculator, arranged to calculate color correction conditions for respective extracted regions; a decider, arranged to decide importance levels for respective extracted regions; a setter, arranged to set a color correction condition for the input image from the color correction conditions calculated for respective regions on the basis of the importance levels; and a corrector, arranged to apply color correction to the input image on the basis of the set color correction condition. 